//
// Created by hentai on 24-12-28.
//
#include "cppl/hentai_base.h"

#include <iostream>
#include <fstream>
#include <vector>
#include <array>

using namespace std;



void change(int &i, int &j) {
    const int temp = i;
    i = j;
    j = temp;
}

double add(const double a, const double b) {
    return a + b;
}

void pointFunc() {
    const auto res = pointFuncFunc(add);
    cout << res << endl;
}

double pointFuncFunc(double (*pt)(double, double)) {
    return pt(1.0, 2.0);
}

void intInput() {
    string input;
    while (cin >> input) {
        cout << input << endl;
    }
}

int file() {
    fstream file;

    string line;
    file.open("text.txt");

    while (getline(file, line)) {
        cout << line << endl;
    }
    file.close();


    file.open("textf.txt", ios::out);
    if (!file.is_open()) {
        cout << "File could not be opened" << endl;
        return 1;
    }
    cin >> line;
    file << line;
    file << line;
    file << line;
    file.close();
    return 0;
}

void collection() {
    vector<int> intVector(10);

    for (int i = 0; i < intVector.size(); i++) {
        intVector[i] = i * 3;
    }

    for (const int i: intVector) {
        cout << i << "\t";
    }
    cout << endl;

    array<int, 10> intArray = {};
    for (int i = 0; i < intArray.size(); i++) {
        intArray[i] = i * 2;
    }

    for (const int i: intArray) {
        cout << i << "\t";
    }
    cout << endl;
}

void pointerPoint() {
    const auto arrayPtr = new int[20];
    for (int i = 0; i < 20; i++) {
        arrayPtr[i] = i * 2;
    }
    cout << arrayPtr << endl;
    for (int i = 0; i < 20; i++) {
        cout << arrayPtr[i] << "\t";
    }
    cout << endl;

    const int *ap20 = &arrayPtr[19];
    const int diff = ap20 - arrayPtr;
    cout << diff << endl;

    delete[] arrayPtr;
}

void stringAndCharArray() {
    string name = "HENTAI LOLICON";

    cout << "Hello " << name.size() << "\t" << name << endl;

    cin >> name;
    cout << name << endl;
    cout << name.size() << endl;

    getline(cin, name);
    cout << name << endl;

    char c[20];
    char ii;

    cin.get(c, 20).get(ii);
    cout << c << endl << ii << endl << endl;
}
